php 7 starts with

38

//php check if first four characters of a string = http
substr( $http, 0, 4 ) === "http";
//php check if first five characters of a string = https
substr( $https, 0, 5 ) === "https";
You can use this in PHP versions less than 8.

<?php
function str_starts_with ( $haystack, $needle ) {
  return strpos( $haystack , $needle ) === 0;
}

Comments

Submit
0 Comments